class Solution:
    def totalMoney(self, n: int) -> int:
        weeks = n // 7
        days = n % 7
        ans = 0
        if weeks==0:
            return (n)*(n+1)//2
        for i in range(1,weeks+1):
            ans+=7*(i+i+6)//2
        for i in range(days):
            ans+=weeks+i+1
        return ans